//
//  SWBasicViewController.swift
//  MYSwiftWeiBo
//
//  Created by shingwai chan on 16/2/27.
//  Copyright © 2016年 ChanShingWai. All rights reserved.
//

import UIKit

class SWBasicViewController: UITableViewController , SWVistorViewDelegate {

    //拿到用户当前是否登陆
    let userLogin = SWUserAccountViewModel.sharedInstance.userLogin
    
    override func loadView() {
        //用户未登陆就显示未登录界面
        userLogin ? super.loadView() : setUpVistorView()
        
    }
    //懒加载
    lazy var vistroView: SWVistorView = SWVistorView()
    
    //未登录界面
    func setUpVistorView() {
    
        self.view = vistroView
        //指定代理
        vistroView.vistorDelegate = self
    
        if (self is SWHomeViewController) { //isKindOfClass = self is xxxxcontroller
            
            vistroView.iconViewRotation()
            
        }else if (self is SWMessengerController) {
        
            vistroView.setupVisitorView("visitordiscover_image_message", messgae: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
            
        }else if (self is SWDiscoverController) {
            
            vistroView.setupVisitorView("visitordiscover_image_message", messgae: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
            
        }else if (self is SWProfileController) {
            
            vistroView.setupVisitorView("visitordiscover_image_profile", messgae: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
        
        }
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "vistorViewRegisterBtnClick")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "vistorViewLoginBtnClick")
    }
    
    //MARK: ----- SWVistorViewDelegate
    //登陆按钮
    func vistorViewLoginBtnClick() {
        
        let oauthVC  = SWOauthController()

        presentViewController(UINavigationController(rootViewController: oauthVC), animated: true, completion: nil)
    }
    //注册按钮
    func vistorViewRegisterBtnClick() {
        
        print("注册")
        
    }

}

